<template>
  <div class="pass-box">
    <div class="pass-content">
      <p class="pass-name">人员出入</p>
      <!--出入分类占比-->
      <ul class="type-length">
        <li v-for="(item, i) in passData" :key="i" :style="{background: item.color, width: chooseWidth(i)}"></li>
      </ul>
      <!--出入分类显示-->
      <div class="pass-legend">
        <div v-for="(item, i) in passData" :key="i"><span :style="{background: item.color}"></span><i>{{ item.name}}</i><b>{{item.num}}</b></div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'peoplePass',
  data () {
    return {
      passData: [{ name: '常驻进', num: 152, color: '#BAD87D' }, { name: '常驻出', num: 108, color: '#50E3C2' }, { name: '访客进', num: 42, color: '#7ACEF4' }, { name: '访客出', num: 36, color: '#4A90E2' }] // 人员进出数据
    }
  },
  methods: {
    chooseWidth (i) {
      let w = (this.passData[i].num / 160) * 230
      return w + 'px'
    }
  }
}
</script>

<style scoped>
  .pass-box {
    width: 100%;
    margin-bottom: 10px;
  }

  .type-length {
    width: 100%;
    margin-top: 5px;
  }

  .type-length li {
    list-style: none;
    height: 10px;
    margin-bottom: 10px;
    margin-right: 2px;
  }

  .type-length li:last-child {
    margin-bottom: 20px;

  }

  .pass-content {
    background: rgba(43, 54, 72, 0.95);
    -webkit-border-radius: 4px;
    -moz-border-radius: 4px;
    border-radius: 4px;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
    position: relative;
  }

  .pass-name {
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 10px;
  }

  .pass-legend {
    height: 70px;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .pass-legend i {
    font-style: normal;
    color: #9FACC3;
    font-size: 12px;
  }

  .pass-legend b {
    float: right;
    font-size: 14px;
    color: #50E3C2;
    font-weight: normal;
  }

  .pass-legend span {
    -webkit-border-radius: 2px;
    -moz-border-radius: 2px;
    border-radius: 2px;
    width: 8px;
    height: 8px;
    display: inline-block;
    /*float: left;*/
    margin-right: 9px;
  }

  .pass-legend div {
    width: 36%;
    line-height: 10px;
    color: #fff;
    margin-right: 30px;
  }
</style>
